package com.shanghai.market.plshnaghai.home.measurement;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shanghai.market.plshnaghai.R;
import com.shanghai.market.plshnaghai.entity.home.measurement.Quizzes;
import com.shanghai.market.plshnaghai.publics.BasePTAdapter;

/**
 * Created by Administrator on 2017/8/29.
 */

public class QuizzesAdapter extends BasePTAdapter<Quizzes> {

    private int index;
    private int selectIndex = -1;

    private String type;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getSelectIndex() {
        return selectIndex;
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public QuizzesAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = mInflater.inflate(R.layout.quizzes_item, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        Quizzes data = mDatas.get(i);
        holder.titleName.setText(index + "." + data.getTopic());
        holder.a.setText(data.getA());
        holder.b.setText(data.getB());
        holder.c.setText(data.getB());

        if (selectIndex == 0) {
            holder.a.setBackgroundResource(R.color.main_warning_text_color);
        } else {
            view.setBackgroundResource(R.color.white);
        }
        if (selectIndex == 1) {
            holder.b.setBackgroundResource(R.color.main_warning_text_color);
        } else {
            view.setBackgroundResource(R.color.white);
        }
        if (selectIndex == 2) {
            holder.c.setBackgroundResource(R.color.main_warning_text_color);
        } else {
            view.setBackgroundResource(R.color.white);
        }
        return view;
    }

    private class ViewHolder {
        private TextView titleName;
        private TextView a;
        private TextView b;
        private TextView c;

        public ViewHolder(View view) {
            titleName = (TextView) view.findViewById(R.id.title_name);
            a = (TextView) view.findViewById(R.id.a);
            b = (TextView) view.findViewById(R.id.b);
            c = (TextView) view.findViewById(R.id.c);
        }
    }
}
